#include "progressdialog.h"
#include "ui_progressdialog.h"

ProgressDialog::ProgressDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ProgressDialog)
{
    ui->setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint);

    ui->progressBar_2->setRange(0,20);
    timer1=new QTimer();
    QObject:: connect( timer1, SIGNAL(timeout()), SLOT(timeDone1()) );   
    timer2=new QTimer();
    QObject:: connect( timer2, SIGNAL(timeout()), SLOT(timeDone2()) );
    count1=0;
    count2=0;
    time=0;

}

ProgressDialog::~ProgressDialog()
{
    delete ui;
}

void ProgressDialog::start(int t)
{   time=t;
    ui->progressBar->setRange(0,t);
    ui->progressBar->setValue(0);
    timer2->start(50);
    timer1->start(1000);

}

void ProgressDialog::stop()
{
    timer1->stop();
    timer2->stop();
    close();
}

void ProgressDialog::timeDone1()
{
 ui->progressBar->setValue(++count1);
 if(count1==time) {timer1->stop();timer2->stop();close();}

}

void ProgressDialog::timeDone2()
{
 ui->progressBar_2->setValue(++count2);
 if(count2==20) {count2=0;}

}
